;Find program for multiple file search.
var ok,day,month,year,hour,minute
name ? 15
#inpend=0
#short

proc print_two(number)
    {
    number=(number mod 10)+(number/10)*16
    printhb bios number;
    }

proc print_date
    {
    print_two(day)
    print bios "-";
    print_two(month)
    print bios "-";
    print_two(year);
    }

proc print_time
    {
    print_two(hour)
    print bios ":";
    print_two(minute)
    }

on error
    {
    print bios
    error msg "\dos.err"
    print bios "!"
    stop
    }

curtoloc
print "FFIND by Peter Campbell, v4."

m=allocate 4096
print "Which files: ";
loctocur
inputs path
if peekb (path+2)=0 then error 999
print cr "Look for: ";
loctocur
inputs table
if peekb (table+2)=0 then error 999
print
find first path+2
goto entry

loop:
find next
entry:
moveb 15 from dta segment|dta offset+30 to name
time=peek dta segment|(dta offset+16h)
date=peek dta segment|(dta offset+18h)
curtoloc
print "File: ";
prints name,0:print "        ";
open #1,name:re=read #1,65535 to m|0:close #1
m[re]b=26
x=0:first=1:lno=1:slno=0

look:
f=x
while m[f]b<>26
    {
    c=m[f]b
    if c=13 then lno++:slno=f+2
    if c=peekb (table+2) then goto look_found
    f++
    }
goto next_one

look_found:
ss=f
gosub look_for_name
#long
if ok then
    {
    #short
    #long
    if first then
	{
	#short
	print bios "File: ";
	mx=name:while peekb mx print bios chr peek mx;:mx++
	day=date and 31
	month=(date/32) and 15
	year=(date/512)+80
	hour=(time/2048)
	minute=(time/32) and 63
	print bios "  ";:print_date
	print bios "  ";:print_time
	print bios:first=0
	}
    print bios "  ";lno;" ";
    word=slno
    col=0
    while m[word]b<>13
	{
	if m[word]b=9 then
	    {
	    xx=(col and 248)+8
	    repeat xx-col print bios " ";
	    col=xx
	    }
	else print bios chr m[word];:col++
	word++
	}
    f=word+1
    print bios
    lno++:slno=f+1
    #long
    }
#short
next_search:
x=f+1
goto look

next_one:
if not first then print bios
test break
goto loop

look_for_name:
ok=0
st=table+2
xs=ss

forever
    {
    next_sb:
    c=m[xs]b
    sb=peekb st
    if sb=0 then ok=1:return
    if sb=' ' then
	{
	if m[xs]b<>' ' then return
	reano:
	while m[xs]b=' ' xs++
	if m[xs]b=9 then xs++:goto reano
	st++:goto next_sb
	}
    if sb='?' then xs++:st++:goto next_sb
    if c<>peekb st then return
    st++
    xs++
    }

path:
string 30

table:
string 50
